#include"Process.h"
#include<time.h>
double speed[] = {0.1,0.01,0.2,0.4,0.05,0.4};
double total = 1024.0;
typedef void (*call_t)(const char* ,double,double);
void download(double total,call_t cb){
    srand(time(NULL));
    double cur = 0.0;
    while(cur<=total){
        cb("下载中",cur,total);
        if(cur>=total)
            break;
        usleep(5000);
        cur+=speed[rand()%6];
        if(cur>total) 
            cur = total;
    }
}
int main(){
    //process();
    download(total,fflushprocess);
    return 0;
}
